package com.groupnections.server.database.solution;

import java.util.ArrayList;
import java.util.List;

import com.google.appengine.api.datastore.Text;
import com.groupnections.shared.entities.Tags;

public class ConvertSolutionToDatabase {

	public static List<Solution> getDatabaseSolutions(
			List<com.groupnections.shared.entities.Solution> solutions,
			String tags) {

		List<Solution> solutionsDatabase = new ArrayList<Solution>();

		for (com.groupnections.shared.entities.Solution solution : solutions) {

			Solution solutionDatabase = new Solution();
			solutionsDatabase.add(getDatabaseSolution(solutionDatabase,
					solution, tags));
		}

		return solutionsDatabase;
	}

	public static Solution getDatabaseSolution(Solution solutionDatabase,
			com.groupnections.shared.entities.Solution solution, String tags) {

		solutionDatabase.setDescription(new Text(solution.getDescription()));

		solutionDatabase.setTags(new Text(Tags.getStaticTags(
				solution.getDescription(), tags)));

		return solutionDatabase;
	}
}
